cmake_minimum_required(VERSION 2.8.3)
project(moying_comm_lib)

add_compile_options(-std=c++11)

find_package(catkin REQUIRED)
find_package(Protobuf REQUIRED)

find_package(PkgConfig)
## use pkg-config to get hints for 0mq locations
pkg_check_modules(ZeroMQ REQUIRED libzmq>=4.3.2)

## use the hint from above to find where 'zmq.hpp' is located
#find_path(ZeroMQ_INCLUDE_DIRS
#        NAMES zmq.hpp
#        PATHS ${ZeroMQ_INCLUDE_DIRS}
#        )

## use the hint from about to find the location of libzmq
find_library(zmq_LIBRARIES
        NAMES zmq
        PATHS ${zmq_LIBRARY_DIRS}
        )

catkin_package(
  INCLUDE_DIRS include
  LIBRARIES moying_comm_lib
  CATKIN_DEPENDS 
  DEPENDS 
)

include_directories(
 include
 ./
 ${catkin_INCLUDE_DIRS}
 ${ZeroMQ_INCLUDE_DIRS}
)

include(cmake/GenerateProtoFiles.cmake)
generate_cpp_pb_files()

file(GLOB SRC_FILES "src/${PROJECT_NAME}/*.cpp")
add_library(${PROJECT_NAME}

  ${SRC_FILES}
  ${proto_cc_files}

)

# target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} )
target_link_libraries(${PROJECT_NAME} ${catkin_LIBRARIES} ${zmq_LIBRARIES} )
add_dependencies(${PROJECT_NAME} ${catkin_EXPORTED_TARGETS} ${Protobuf_LIBRARIES})

#############   
## Install ##
#############

# all install targets should use catkin DESTINATION variables
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html

## Mark executable scripts (Python etc.) for installation
## in contrast to setup.py, you can choose the destination
# install(PROGRAMS
#   scripts/my_python_script
#   DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
# ) 

## Mark executables and/or libraries for installation
 install(TARGETS ${PROJECT_NAME} 
#   ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
   LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
#   RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
 )


## Mark other files for installation (e.g. launch and bag files, etc.)
# install(FILES
#   moying_commu.h
#   # myfile2
#   DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
# )

#配置包含的头文件（安装后可在/opt/ros/kinetic/include/${PROJECT_NAME}路径下找到该头文件）
install(DIRECTORY include/${PROJECT_NAME}/

  DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
 
)

#############
## Testing ##
#############
 
## Add gtest based cpp test target and link libraries
# catkin_add_gtest(${PROJECT_NAME}-test test/test_moying_comm_lib.cpp)
# if(TARGET ${PROJECT_NAME}-test)
# endif()## Add folders to be run by python nosetests
# catk